package com.codi.bus.core.service;

import com.codi.base.exception.BaseAppException;
import com.codi.bus.core.domain.User;
import com.codi.bus.core.domain.UserBank;
import com.codi.bus.core.resultModel.*;
import com.codi.bus.core.service.model.*;
import com.codi.bus.exception.BaseException;
import com.codi.bus.util.FundOperation;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface QueryService {

    PortfolioApplyListResult queryPortfolioApplys(Long userId, Integer requestNum, Integer queryFlag, Integer beginNum,
                                                  String sortDirection, boolean filterT0) throws BaseException;


    /**
     * 交易确认查询
     * @param userId
     * @param requestNum
     * @param queryFlag
     * @param beginNum
     * @param sortDirection
     * @param fundCode
     * @param businCode
     * @param beginDate
     * @param endDate
     * @param confirmFlag
     * @return
     */
    CollectionResult<ConfirmModel> queryTradeConfirms(Long userId, Integer requestNum, Integer queryFlag, Integer beginNum,
                                                             String sortDirection, String fundCode, String businCode, Date beginDate, Date endDate, String confirmFlag);
    /**
     * 查询某只基金
     *
     * @param fundCode
     * @return
     */
    FundModel queryFund(String fundCode);

    // 基金查询
    FundListResult queryFunds(Integer requestNum, Integer queryFlag, Integer beginNum, String sortDirection,
                              String fundCode) throws BaseException;

    // 份额查询
    ShareListResult queryShares(Long userId, Integer requestNum, Integer queryFlag, Integer beginNum,
                                String sortDirection, boolean filterT0) throws BaseException;

    // 交易申请查询  非组合基金
    ApplyListResult queryApplys(Long userId, Integer requestNum, Integer queryFlag, Integer beginNum,
                                String sortDirection, boolean filterT0) throws BaseException;

//    // 组合交易查询
//    PortfolioSummaryResult portfolioApplys(Long userId, Integer requestNum, Integer queryFlag, Integer beginNum,
//                                String sortDirection, boolean filterT0) throws BaseException;

    // 份额类别查询
    ShareTypeListResult queryShareTypes(Integer requestNum, Integer queryFlag, Integer beginNum, String sortDirection,
                                        String fundCode, String fundName) throws BaseException;

    // 客户银行帐号查询
    BaseListResult queryAccountBanks(String tradeAccount, String clientId, String capitalMode, Integer requestNum,
                                     Integer queryFlag, Integer beginNum, String sortDirection) throws BaseException;

    //非组合基金份额查询
    ShareListResult querySharesWithoutPort(Long userId, Integer requestNum, Integer queryflag, Integer beginNum,
                                           String sortDirection, boolean filterT0) throws BaseException;

    BaseResult queryFundShares(Long userId,  boolean filterT0, String fundCode) throws BaseException;

    Date maxDate();

    void filterT0(List<ApplyModel> applys, boolean filterT0);

    void filterOrganBao(List<ApplyModel> applys);

    void getOrganBao(List<ApplyModel> applys);

    BigDecimal getLastUnitValue(String fundCode, Date currentWorkingDate);

    // 根据基金代码查询基金费率
    List<FundRate> queryFundRate(String fund_code, FundOperation operation);

    // 获取基金申购费率
    FundTradeRatio getApplyFundRate(String fund_code, BigDecimal balance, String custType);

    // 获取基金赎回费率
    FundTradeRatio getExceedFundRate(String fund_code, BigDecimal balance, String custType);

    // 交易限制查询
    TradeLimitListResult queryTradeLimits(Integer requestNum, Integer queryFlag, Integer beginNum, String sortDirection,
                                          String fundCode, String shareType, String capitalMode, String businCode, String customType)
        throws BaseException;

    // 获取基金申购、赎回的最低数量
    TradeLimitModel getTradeLimit(String fundCode, String businCode, String shareType, String customType,
                                  String capitalMode) throws BaseException;



    // 获取基金的风险等级
    NewsModel getRiskLevel(String fundCode) throws BaseException;

    // 查询某一笔的交易
    ApplyModel queryApply(String applyNo) throws BaseException;


    /**
     * 查询单挑组合申请交易
     *
     * @param portfolioApplyNo
     * @return
     * @throws BaseAppException
     * @author spy 2017-11-13 14:02:03
     */
    ApplyModel queryPortfolioApply(String portfolioApplyNo);

    /**
     * TA账号查询
     *
     * @param clientId 客户编号
     * @return 账户列表
     * @throws BaseException
     */
    TAListResult queryTAAccounts(String clientId) throws BaseException;

    /**
     * 根据基金代码获折扣信息
     *
     * @param fund_code
     */
    List<FundDiscountSetting> queryFundDiscountSettings(String fund_code, FundOperation operation);

    // 获取主交易账号
    AccountModel getMainAccount(String clientId) throws BaseException;

    // 获取份额类别
    ShareTypeModel getShareType(String fundCode) throws BaseException;

    /**
     * 基金定投
     *
     * @return 已参与定投的基金列表
     * @throws BaseException
     */
    FixListResult getFixes(Long userId, Integer requestNum, Integer queryFlag, Integer beginNum, String sortDirection)
        throws BaseException;

    /**
     * 获取用户零钱包的交易记录
     *
     * @author hzren
     * @since pangu003
     */
    ApplyListResult queryWalletOperationList(Long userId, Integer requestNum, Integer queryFlag, Integer beginNum,
                                             String sortDirection, String fundCode);

    /**
     * 我的资产页面数据查询 -Shangdu Lin
     *
     * @param userId
     * @return
     * @throws BaseException
     */
    AssetsResult queryAssets(Long userId) throws BaseException;

    AssetsResult queryFundAssets(Long userId) throws BaseException;

    /**
     * 我的资产页面查询瑞富宝数据
     *
     * @param userId
     * @return
     * @throws BaseException
     */
    AssetsResult queryWalletAssets(Long userId) throws BaseException;

    /**
     * 组合查询
     *
     * @param userId
     * @return
     * @throws BaseException
     */
    AssetsPortfolioResult queryPortfolioAssets(Long userId) throws BaseException;

    /**
     * 我的资产页面 机构版数据查询 -zhenhao wang
     */
    AssetsResult queryOrganAssets(Long userId) throws BaseException;

    /**
     * Shangdu Lin: 查询某一用户下的某一时间段的所有交易记录, 此方法被用于计算当前交易日T0基金快速赎回限制
     *
     * @param userId
     * @param beginDate
     * @param endDate
     * @param onlyT0
     * @return
     * @throws BaseException
     */
    ApplyListResult queryApplys(Long userId, Date beginDate, Date endDate, String businCode, String confirmFlag,
                                boolean onlyT0) throws BaseException;


    void stocks(PortfolioModel portfolioModel, List<PortfolioQryModel> fundList, Long userId);

    PortfolioModel queryPortfolioFunds(Long userId, String portfolioCode) throws BaseException;


    /**
     * 查询基金的交易限制 - Shangdu Lin - 20170330
     * 没有指定资金模式，没有指定客户类型，不推荐使用 2017-10-12 11:17:57
     *
     * @param fundCode
     * @return
     */
    @Deprecated
    List<TradeLimitModel> queryTradeLimits(String fundCode);

    List<TradeLimitModel> queryTradeLimits(String fundCode, boolean isRedemptionPurchase);

    /**
     * 获取基金的交易限制 - Shangdu Lin - 20170330
     *
     * @param fundCode
     * @param capitalMode
     * @param businCode
     * @param customType
     * @return
     */
    List<TradeLimitModel> queryTradeLimits(String fundCode, String capitalMode, String businCode,
                                           String customType);

    /**
     * 查询警示内容
     *
     * @return
     */
    List<WarningModel> queryWarnings();


    /**
     * 查询账户申请状态
     *
     * @param clientId
     */
    AccountApplyModel queryAccountLatestApply(String clientId);

    /**
     * 查询推荐基金
     *
     * @return
     */
    RecommendedFundModel queryRecommendedFund();

    BaseResult changePlace();

    List<DividendModel> getDividend(User user, List<UserBank> userBankList);



    List<PortfolioQryModel> getPortfolioQryModel (User user);


    /**
     * 判断所属银行卡是否有份额
     */
    BaseResult checkSharesExistByBankAccount(Long userId, String bankAccount, String capitalMode);



    AssetsResult queryAccumlateIncomeForProfit(Long userId) throws BaseException;

    void setClient();
}
